package d1227;

import java.util.ArrayList;
import java.util.List;

public class Solution {
    private int[] age;
    public int numFriendRequests(int[] ages) {
        this.age = ages;
        int size = ages.length;
        int count = 0;
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < size; j++) {
                if (i == j)
                    continue;
                if (send(i, j))
                    count++;
            }
        }
        return count;
    }

    private boolean send(int x, int y) {
        if (age[y] <= 0.5 * age[x] + 7) {
            return false;
        }
        if (age[y] > age[x]) {
            return false;
        }
        if (age[y] > 100 && age[x] < 100) {
            return false;
        }
        return true;
    }

    public static void main(String[] args) {
//        List<Integer> list = new ArrayList<>();
        int[] arr = {20,30,100,110,120};
        int num = new Solution().numFriendRequests(arr);
        System.out.println(num);
    }
}
